import Taro, { General } from "@tarojs/taro";

export const toast = (msg: string): Promise<General.CallbackResult> => {
  return Taro.showToast({ title: msg, icon: "none", duration: 1500 });
};


export function api_toast(e: any, fallback?: string) {
  const title = getApiErrorMessage(e) || fallback || "服务器开小差啦~";
  toast(title);
}

export function getApiErrorMessage(e: any) {
  return e && (e.msg || e.message);
}
